<%--
  Created by IntelliJ IDEA.
  User: 栋
  Date: 2022/12/3
  Time: 15:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <%@include file="/pages/base/base.jsp"%>
    <script>
        function payTotal(){
            var pay = document.querySelector('.pay');
            var mask = document.querySelector('.pay-bg');
            mask.style.display = 'block';
            pay.style.display = 'block';
            var title="共需"+document.getElementById("total").innerText;
            document.getElementById("need").textContent=title;
        }
        function closeZhiFu(){
            var pay = document.querySelector('.pay');
            var mask = document.querySelector('.pay-bg');
            mask.style.display = 'none';
            pay.style.display = 'none';
        }

        function pay(){
            var r=confirm("是否确认付款");
            if(r==true){
                var credit_pwd=document.getElementById("password").value;
                window.location.href="userServlet?action=payAll&credit_pwd="+credit_pwd;

            }
        }
    </script>
</head>
<body>
<div class="container">
    <%@include file="/pages/base/head.jsp"%>
    <%@include file="/pages/base/topnav_afterLogin.jsp"%>
    <div class="errorMsg">
        ${requestScope.msg }
    </div>
    <c:if test="${sessionScope.car.cnt!=0}">
        <table id="personalItems_tb">
            <tr>
                <th>商品编号</th>
                <th>商品名称</th>
                <th>购买数量</th>
                <th>交易方式</th>
                <th>地址</th>
                <th>总价</th>
                <th>管理</th>
            </tr>
            <c:forEach items="${sessionScope.car.lst}" var="order">
                <tr>
                    <td>${order.item_id}</td>
                    <td>${order.item_name}</td>
                    <td>${order.buy_count}</td>
                    <td>${order.method}</td>
                    <td>${order.address}</td>
                    <td>￥${order.total_price}</td>
                    <td><a href="userServlet?action=deleteFromCar&item_id=${order.item_id}">删除</a></td>
                </tr>
            </c:forEach>
            <tr>
                <td>
                    共计
                </td>
                <td id="total" colspan="6">
                    ￥${sessionScope.car.totalPrice}
                </td>
            </tr>
        </table>
        <div class="button" style="width: 100%">
            <button style="margin: auto" onclick="payTotal()">付款</button>
        </div>

    </c:if>

    <div id="pay" class="pay">
        <div id="title" class="pay-title">银行卡密码
            <span><a id="closeBtn" href="javascript:void(0);" class="close-pay" onclick="closeZhiFu()">关闭</a></span>
        </div>
        <div id="need" style="text-align: center">

        </div>
        <div class="pay-input-content">
            <div class="pay-input">
                <label>支付密码：</label>
                <input type="password" placeholder="请输入银行卡密码" name="info[password]" id="password" class="list-input">
            </div>
        </div>
        <div id="pay_btn" class="pay_btn"><a href="javascript:void(0);" id="button-submit" onclick="pay()">提交</a></div>
    </div>
    <!-- 遮盖层 -->
    <div id="bg" class="pay-bg"></div>
</div>
</body>
</html>
